<?php
namespace app\shop\controller;
class Index extends Base{

    function init(){
        //查询商品数量
        $sellcount = $this->db->query("select count(*) as count from goods where status = ? and shop_id = ?",[0,$this->userinfo['id']],1);
        $nocount = $this->db->query("select count(*) as count from goods where status = ? and shop_id = ?",[1,$this->userinfo['id']],1);
        //订单数量
        //未支付
        $npc = $this->db->query("select count(*) as count from order_goods where pay_status = ?",[0],1);
        //未发货
        $nfc = $this->db->query("select count(*) as count from order_goods where pay_status = ? and fahuo_status = ? and shop_id = ?",[1,0,$this->userinfo['id']],1);
        //已发货
        $ofc = $this->db->query("select count(*) as count from order_goods where pay_status = ? and fahuo_status = ? and shop_id = ?",[1,0,$this->userinfo['id']],1);
        $this->fetch([
            'sellcount'=>$sellcount,
            'nocount'=>$nocount,
            'npc'=>$npc,
            'nfc'=>$nfc,
            'ofc'=>$ofc,
        ]);
    }


    //导航跳转中专
    function nav(){
        clear_cookie_arr('nav');
        $id = $this->get('id');
        switch ($id) {
            case 'goods':
                $d = [
                    ['/goods/goodsCat','发布商品'],
                    ['/goods/lists','商品列表'],
                ];
                break;
            case 'wuliu':
                $d = [
                    ['/fahuo/lists','物流管理'],
                ];
                break;
            case 'order':
                $d = [
                    ['/order/lists','订单管理'],
                ];
                break;
            case 'shop':
                $d = [
                    ['/shop/edit','店铺设置'],
                ];
                break;
            default:
                $d = [
                    ['/index/init','首页'],
                ];
                break;
        }
        $url = '';
        foreach($d as $k => $v){
            if($k==0) $url = $v[0];
            cookie('nav_'.$k, $v[0].'|'.$v[1]);
        }
        log_test('cookie',$_COOKIE);
        r(url(ltrim($url,'/')));
    }
}
?>
